﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BattleMaster_IRCbot.UserCommands
{
    class Attack : Command
    {
        public override string Name { get { return _name; } }
        public override string[] Aliasses { get { return _aliasses; } }
        public override string Description { get { return _description; } }
        public override string ShortDesc { get { return _shortDesc; } }

        public Attack()
        {
            _name = "Attack";
            _aliasses = new string[] { };
            _description = "This command is used to attack another player.";
            _shortDesc = "Use this to kill someone!";
        }

        public override void Verb(Game game, string msgOrigen, string[] cmd)
        {
            bool targetExists = false;
            if (msgOrigen != "console")
            {
                try
                {
                    foreach (Character C in game.Characters)
                    {
                        if( cmd[1].ToLower() == C.Name.ToLower()  )
                        {
                            targetExists = true;
                            game.ircHandler.Broadcast(String.Format("{0} attacks {1} for 10 DMG!", msgOrigen, cmd[1]));
                            C.HitPoints -= 10;
                            break;
                        }
                    }
                    if (!targetExists) game.ircHandler.sendNotice(msgOrigen, "Target not found.");
                }
                catch (IndexOutOfRangeException ex) { game.ircHandler.sendNotice(msgOrigen, "--Bad Arguments--"); }
            }
        }
    }
}
